<?php
/**
 * Created by b17
 * 2/15/12 8:50 PM
 */

namespace Managers;

class Mailer
{
    protected $transport;

    /**
     * @var \Zend_Mail[]
     */
    protected $messages = array();

    public function __construct()
    {
        $config = array('name' => 'sender.example.com');
        $this->transport = new \Zend_Mail_Transport_Smtp('mail.example.com', $config);
    }

    public function addMessage(\Zend_Mail $message)
    {
        $this->messages[] = $message;
        return $this;
    }

    public function send()
    {
        foreach ($this->messages as $message) {
            $message->send($this->transport);
        }
        $this->clear();
    }

    public function clear()
    {
        $this->messages = array();
    }
}
